package cn.project.lemontree.service.impl;

import cn.project.lemontree.bean.Child;
import cn.project.lemontree.bean.Parent;
import cn.project.lemontree.bean.ParentChild;
import cn.project.lemontree.dao.ParentChildDao;
import cn.project.lemontree.service.ParentChildService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ParentChildServiceImpl extends ServiceImpl<ParentChildDao,ParentChild> implements ParentChildService {
    @Resource
    private  ParentChildDao parentChildDao;
    @Override
    public List<ParentChild> listpage(int page, int size, String childName, String parentName) {
        return parentChildDao.listPage((page-1)*size,size,childName,parentName);
    }

    @Override
    public int count(String childName, String parentName) {
        return parentChildDao.count(childName,parentName);
    }

    @Override
    public boolean remove(Integer childId, Integer parentId) {
        return parentChildDao.remove(childId,parentId)>0;
    }

    @Override
    public List<Parent> findAllByChild(Integer childId, String childName) {
        return parentChildDao.findAllByChild(childId,childName);
    }

    @Override
    public List<Child> findAllByParent(Integer parentId, String parentName) {
        return parentChildDao.findAllByParent(parentId,parentName);
    }

    @Override
    public boolean save(Parent parent,Child child) {
        return parentChildDao.save(parent,child)>0;
    }


}
